import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
    //配置持久化的插件数据
import vuexPersist from 'vuex-persist';

//创建对象配置持久化
const vuexLocal = new vuexPersist({
    //定义本地存储的方式，sessionStorage或localStorage
    storage: window.localStorage,
});


export default new Vuex.Store({
    state: {
        goods: "",
        name: "",
        user_id: 0
    },
    mutations: {
        goods(state, e) {
            state.goods = e
        },
        name(state, e) {
            state.name = e
        },
        del(state) {
            state.name = ""
            state.user_id = 0
        },
        ID(state, id) {
            state.user_id = id
        }
    },

    getters: {

    },
    //配置插件持久化的插件值
    plugins: [vuexLocal.plugin]
})